var zhWeekDays = ['日', '一', '二', '三', '四', '五', '六'];
var mobiscroll;

function selectTime() {
    var $selects = $('.selects');
    $selects.mobiscroll();
    var dateValues = [];
    var now = new Date();
    var n, m;
    var md, hn;
    for (n = 0; n < 6; n++) {
        m = now.getMonth() + 1;
        var d = now.getDate();
        md = m + '月' + d + '日 周' + zhWeekDays[now.getDay()];
        dateValues.push(md);
        now.setDate(d + 1);
    }
    var timeValues = [];
    for (n = 0; n < 24; n++) {
        for (m = 0; m < 60; m += 10) {
            hn = (n < 10 ? '0' : '') + n + ':' + (m < 10 ? '0' : '') + m;
            timeValues.push(hn);
        }
    }
    $selects.scroller({
        rows: 5,
        wheels: [
            [
                {
                    values: dateValues
                },
                {
                    values: timeValues
                }
            ]
        ],
        display: 'inline',
        layout: 'liquid'
    });


    var selectedDate;
    var tDate = new Date();
    m = Math.ceil(tDate.getMinutes() / 10) * 10 + 10;
    tDate.setMinutes(m);
    selectedDate = tDate;

    m = selectedDate.getMonth() + 1;
    d = selectedDate.getDate();
    h = selectedDate.getHours();
    n = selectedDate.getMinutes();

    md = m + '月' + d + '日 周' + zhWeekDays[selectedDate.getDay()];
    hn = (h < 10 ? '0' : '') + h + ':' + (n < 10 ? '0' : '') + n;
    mobiscroll = $selects.mobiscroll('getInst');
    mobiscroll.setArrayVal([md, hn]);
    $selects.show();
    return false;
}

$(function () {
    // selectTime();

    mobiscroll.scroller('#scroller', {
        // theme: 'mobiscroll',
        display: 'inline',
        // showLabel: true,
        wheels: [
            [
                {
                    label: 'First wheel',
                    data: ['0x', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10',
                        '11', '12', '13', '14', '15', '16'],
                    circular: false
                },
                {
                    label: 'Second wheel',
                    data: [{
                        value: 0,
                        display: 'a'
                    }, {
                        value: 1,
                        display: 'b'
                    }, {
                        value: 2,
                        display: 'c'
                    }, {
                        value: 3,
                        display: 'd'
                    }]
                }
            ]
        ]
    });

});
